package com.woniuxy.lab.woniu_lab_boss.config;

import com.woniuxy.lab.woniu_lab_boss.util.PathUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        // 配置资源映射
        String fileSavePath = PathUtil.getFileSavePath();
        registry.addResourceHandler("/files/**")// 刚上传文件时的映射
                .addResourceLocations("file:"+ fileSavePath);
        registry.addResourceHandler("/file/**")// 移动文件后的映射
                .addResourceLocations("file:" + PathUtil.linuxSavePath);
    }

}



